﻿<?xml version="1.0" encoding="utf-8"?><Articles><Article><ArticlesID>575</ArticlesID><Title>Kiểm tra địa chỉ Email với Javascript</Title><Body>&amp;lt;pre title=&amp;quot;code&amp;quot; class=&amp;quot;brush: jscript;&amp;quot;&amp;gt;
function echeck(str) {

    var at = &amp;amp;quot;@&amp;amp;quot;
    var dot = &amp;amp;quot;.&amp;amp;quot;
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (str.indexOf(at) == -1) {
        //alert(&amp;amp;quot;Email sai định dạng.&amp;amp;quot;)
        return false
    }

    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        //alert(&amp;amp;quot;Email sai định dạng.&amp;amp;quot;)
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        //alert(&amp;amp;quot;Email sai định dạng&amp;amp;quot;)
        return false
    }

    if (str.indexOf(at, (lat + 1)) != -1) {
        //alert(&amp;amp;quot;Email sai định dạng.&amp;amp;quot;)
        return false
    }

    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        //alert(&amp;amp;quot;Email sai định dạng.&amp;amp;quot;)
        return false
    }

    if (str.indexOf(dot, (lat + 2)) == -1) {
        //alert(&amp;amp;quot;Email sai định dạng.&amp;amp;quot;)
        return false
    }

    if (str.indexOf(&amp;amp;quot; &amp;amp;quot;) != -1) {
        //alert(&amp;amp;quot;Email sai định dạng.&amp;amp;quot;)
        return false
    }
    return true
}&amp;lt;/pre&amp;gt;</Body><CommentEnabled>True</CommentEnabled><ViewCount>0</ViewCount><ReleaseDate>11/1/2009 12:16:38 AM</ReleaseDate><TotalComment>0</TotalComment><IsMedia>False</IsMedia><IsPicture>False</IsPicture><IsVote>True</IsVote><ArticlePassword /><PostVisible>0</PostVisible><ArticlePath>/2009/11/1/Kiem-tra-dia-chi-Email-voi-Javascript-23F</ArticlePath><Approved>True</Approved><ImagePath /><CategoryId>30</CategoryId><ArrayCatID>30|25</ArrayCatID></Article></Articles>